//
// Created by ChaoDONG on 2021-03-17.
//

// min_sec.c -- converts seconds to minutes and seconds
/* min_sec.c -- 把秒数转换成分和秒 */

#include <stdio.h>

#define SEC_PER_MIN 60 /* 1分钟60秒 */

int main(void)
{
    int sec, min, left;

    printf("Convert seconds to minutes and seconds!\n");

    printf("Enter the number of seconds (<=0 to quit):\n");

    scanf("%d", &sec); // read number of seconds

    while (sec > 0)
    {
        min = sec / SEC_PER_MIN; // truncated number of minutes

        left = sec % SEC_PER_MIN; // number of seconds left over

        printf("%d seconds is %d minutes, %d seconds.\n",
               sec,min, left);

        printf("Enter next value (<=0 to quit):\n");

        scanf("%d", &sec);
    }

    printf("Done!\n");

    return 0;
}